import sys
from os.path import abspath, join, dirname
# 插入proto目录到sys.path
sys.path.insert(0, join(abspath(dirname(__file__)), "../"))
from mqtt.mqtt_publish import MqttPublish
from mqtt.common.common_constant import CommonConstant
from mqtt.method.remote_control_method import RemoteControlMethodEnum
class DevControlApi:
    def __init__(self):
        self.mqtt_publish = MqttPublish()

    # 双击成为aim
    def aim_at(self, gateway_sn, data):
        self.mqtt_publish.publish_with_method(gateway_sn=gateway_sn,
                                              suffix=CommonConstant.TOPIC_DRC_DOWN_SUFFIX,
                                              data=data,
                                              method=RemoteControlMethodEnum.CAMERA_AIM.get_method())

    # 摄像头对准目标
    def look_at(self, gateway_sn, data):
        self.mqtt_publish.publish_with_method(gateway_sn=gateway_sn,
                                              suffix=CommonConstant.TOPIC_DRC_DOWN_SUFFIX,
                                              data=data,
                                              method=RemoteControlMethodEnum.CAMERA_LOOK_AT.get_method())

    # 开始拍照
    def photo_take(self, gateway_sn, data):
        self.mqtt_publish.publish_with_method(gateway_sn=gateway_sn,
                                              suffix=CommonConstant.TOPIC_DRC_DOWN_SUFFIX,
                                              data=data,
                                              method=RemoteControlMethodEnum.CAMERA_PHOTO_TAKE.get_method())


    # 停止拍照
    def photo_stop(self, gateway_sn, data):
        self.mqtt_publish.publish_with_method(gateway_sn=gateway_sn,
                                              suffix=CommonConstant.TOPIC_DRC_DOWN_SUFFIX,
                                              data=data,
                                              method=RemoteControlMethodEnum.CAMERA_PHOTO_STOP.get_method())
